mui.init();

var old_back = mui.back;
mui.back = function(){
	//显示上一个界面；
	var goback = plus.storage.getItem('goback');
	if(goback=='1'){
		window.frames[0].window.history.back();
		
	}else{
		old_back();
	}
}

mui.plusReady(function() {
	renderDatas();
	var currWebView = plus.webview.currentWebview();
	plus.storage.setItem('goback',0);
	var btn_login = CmwMcore.$("btn_login");
	MeventMgr.onTouchstart(btn_login,function(event,self){
		var dis=$("#btn_login").attr("disabled")//判断是否有这属性
			if(dis)return;
		plus.storage.setItem('goback',1);
		var bankNo = currWebView.bankNo;
		var tradeAmount = currWebView.tradeAmount;
		var tradeNum = currWebView.tradeNum;
		CmwMcore.disabled('btn_login');
		var formDatas = {bankNo:bankNo,tradeAmount:tradeAmount,tradeNum:tradeNum};
		var url = UrlConfig.mrecharge_signnn;
		MuiEventMgr.ajax(url,{
		  	pars:formDatas,
		  	sfn : function(data){
		  		callback();
	        	CmwMcore.enabled('btn_login');
		  	},ffn : function(data){
		  		CmwMcore.enabled('btn_login');
		  	}
		 });
		return false;
	});
	
});

function callback(){
	var formEle = document.getElementById("theForm");
	formEle.submit();
	$("#cmw_container").hide();
	$("#if_recharge").show(); 
}

function renderDatas(){
	var currWebView = plus.webview.currentWebview();
	var bankName = currWebView.bankName;
	var bankAccount = currWebView.bankAccount;
	var bankNo = currWebView.bankNo;
	var tradeAmount = currWebView.tradeAmount;
	var tradeNum = currWebView.tradeNum;
	var tradeInfo = currWebView.tradeInfo;
	//sp_orderNo,sp_bankName,sp_bankAccount,sp_tradeAmount
	$("#sp_orderNo").text(tradeNum);
	$("#sp_bankName").text(bankName);
	$("#sp_bankAccount").text(bankAccount);
	$("#sp_tradeAmount").text(tradeAmount);
	if(!tradeInfo){
		mui.alert("支付请求数据 tradeInfo 不能为空!");
		return;
	}
	for(var key in tradeInfo){
		var val = tradeInfo[key];
		if(key == "specifyInfoJson"){
			val = JSON.stringify(val);
		}
		var ele = $("#"+key);
		if(!ele) continue;
		ele.val(val);
	}
}